const router = require("koa-router")();
router.prefix("/role_user-api")
const { queryDocumentList } = require("../../../controller/system/user/r_role_user");
const { serverError } = require("../../../utils");
const pageSizeList = require("../../../utils/slicePageSize");

/**@description 查询角色分组页面下的成员列表 */
router.post("/getlist", async (ctx, next) => {
    try {
        const { roleId = null, roleName = null, userName = null, userId = null, pageSize, current } = ctx.request.body;
        const list = await queryDocumentList({
            // roleId: "66312e49a0e59b8b068cd3a9",
            // roleName: "管理员",
            // userName: "牧夕",
            // userId: "admin"
            roleId, roleName, userName, userId
        })
        console.log("查询结果：\n", list);
        ctx.body = {
            status: "0000",
            message: "查询成功",
            data: {
                total: list.length,
                list: pageSizeList({
                    data: list,
                    pageSize,
                    current
                })
            }
        }
    } catch (error) {
        // console.log("错误：", error);
        ctx.body = serverError
    }
})

const query = async (ctx, next) => {
    try {
        const { roleId = null, roleName = null, userName = null, userId = null } = ctx.body.request;
        const list = await queryDocumentList({
            // roleId: "66312e49a0e59b8b068cd3a9",
            // roleName: "管理员",
            // userName: "牧夕",
            // userId: "admin"
            roleId, roleName, userName, userId
        })
        console.log("查询结果：\n", list);
    } catch (error) {
        console.log("错误：", error);
    }
}

module.exports = router;

// add();
// query();

